package com.deneme.ozveri.clicklisteners;

import java.util.ArrayList;

import com.deneme.ozveri.activities.FrameMenuAlphaActivity;
import com.deneme.ozveri.adapters.MenuItemListAdapter;
import com.deneme.ozveri.database.DBHandler;
import com.deneme.ozveri.objects.MenuItem;
import com.deneme.ozverimenu.R;

import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.TextView;

public class MainItemOnClickListener implements OnItemClickListener {

	ArrayList<MenuItem> mainList;
	ArrayList<MenuItem> subList;
	DBHandler dh;
	Activity act;
	ListView subMenuList;

	public MainItemOnClickListener(ArrayList<MenuItem> mainListObjects,DBHandler databaseHandler, Activity actvt ,ArrayList<MenuItem> subListObjects) {
		mainList = mainListObjects;
		subList = subListObjects;
		dh = databaseHandler;
		act = actvt;
		this.subMenuList =  (ListView) actvt.findViewById(R.id.menu_sub_menulist_listview);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {


		subList = dh.getSubMenuItems(mainList.get(arg2).getMenuId());
		subMenuList.setAdapter(new MenuItemListAdapter(subList, arg1.getContext()));
		subMenuList.setOnItemClickListener( new SubItemOnClickListener(act, dh,subList));
		
		subMenuList.setVisibility(View.VISIBLE);
		
		subMenuList.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 20));

		
		((LinearLayout)act.findViewById(R.id.menu_helper_linear)).setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 60));
		((TextView)act.findViewById(R.id.menu_helper_txt)).setText("Lutfen Sol Taraftan Alt Menu Seciniz");






	}

}
